package de.doegel.common.widget;

import android.content.ContentResolver;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ListAdapter;

/**
 * An implementation of a Cursor that is almost useless. It is simply used
 * for the SectionIndexer to browse our underlying data.
 * 
 * @author Cyril Mottier
 */
public class FakeCursor implements Cursor {	
	private ListAdapter mAdapter;
	private int mPosition;

	public FakeCursor(ListAdapter adapter) {
		mAdapter = adapter;
	}

	public void close() {
	}

	public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
	}

	public void deactivate() {
	}

	public byte[] getBlob(int columnIndex) {
		return null;
	}

	public int getColumnCount() {
		return 0;
	}

	public int getColumnIndex(String columnName) {
		return 0;
	}

	public int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException {
		return 0;
	}

	public String getColumnName(int columnIndex) {
		return null;
	}

	public String[] getColumnNames() {
		return null;
	}

	public int getCount() {
		return mAdapter.getCount();
	}

	public double getDouble(int columnIndex) {
		return 0;
	}

	public Bundle getExtras() {
		return null;
	}

	public float getFloat(int columnIndex) {
		return 0;
	}

	public int getInt(int columnIndex) {
		return 0;
	}

	public long getLong(int columnIndex) {
		return 0;
	}

	public int getPosition() {
		return 0;
	}

	public short getShort(int columnIndex) {
		return 0;
	}

	public String getString(int columnIndex) {
		final Object item = mAdapter.getItem(mPosition);
		return item.toString().substring(0, 1).toUpperCase();
	}

	public boolean getWantsAllOnMoveCalls() {
		return false;
	}

	public boolean isAfterLast() {
		return false;
	}

	public boolean isBeforeFirst() {
		return false;
	}

	public boolean isClosed() {
		return false;
	}

	public boolean isFirst() {
		return false;
	}

	public boolean isLast() {
		return false;
	}

	public boolean isNull(int columnIndex) {
		return false;
	}

	public boolean move(int offset) {
		return false;
	}

	public boolean moveToFirst() {
		return false;
	}

	public boolean moveToLast() {
		return false;
	}

	public boolean moveToNext() {
		return false;
	}

	public boolean moveToPosition(int position) {
		if (position < -1 || position > getCount()) {
			return false;
		}
		mPosition = position;
		return true;
	}

	public boolean moveToPrevious() {
		return false;
	}

	public void registerContentObserver(ContentObserver observer) {
	}

	public void registerDataSetObserver(DataSetObserver observer) {
	}

	public boolean requery() {
		return false;
	}

	public Bundle respond(Bundle extras) {
		return null;
	}

	public void setNotificationUri(ContentResolver cr, Uri uri) {
	}

	public void unregisterContentObserver(ContentObserver observer) {
	}

	public void unregisterDataSetObserver(DataSetObserver observer) {
	}
}
